<%@ include file="/WEB-INF/views/taglib.jsp" %>
<c:set var="systemUser" value="${systemUserForm.systemUser}"></c:set>
<c:url value="/ajax/section" var="sectionUrl"></c:url>
<br />
<h3>&nbsp;User Form</h3>	
	<form:form id="form" method="post" modelAttribute="systemUserForm" cssClass="simpleForm">
		<form:hidden path="formMode" />
		
	 	<div class="clear" style="height:1px">&nbsp;</div>
		<jsp:include page="/WEB-INF/views/message.jsp"></jsp:include>
	  	<fieldset>
	  		<legend>Account Info</legend>
	  		<div class="span-11">
	  		<aims:column cssErrorClass="error" path="systemUser.userName" cssClass="clearfix">
	  		<form:label path="systemUser.userName">
	  			User Name  *  
	 		</form:label>
	 		<c:choose>
	  		<c:when test="${systemUserForm.systemUser.lastModifiedDate!=''}">
	  		<form:input path="systemUser.userName" disabled="true" />
	  		<form:hidden path="systemUser.userName"/>
	  		</c:when>
	  		<c:otherwise>
	  		<form:input path="systemUser.userName" />
	  		</c:otherwise>
	  		</c:choose>
	  		 <form:errors path="systemUser.userName"  cssClass="errorSimple" />
			</aims:column>
			<aims:column cssErrorClass="error" path="systemUser.superAdmin">
	  		<form:hidden path="systemUser.superAdmin" value="0" /> 
			</aims:column>
			<aims:column cssErrorClass="error" path="systemUser.active" cssClass="clear">
	  		<form:label path="systemUser.active">
	  			Status
	 		</form:label>
	 			
	  		<form:select path="systemUser.active" disabled="true">
	  		<form:options items="${globalActiveMap}" />	
	  		</form:select>
			</aims:column>
	  		</div>
	  		
	  		<div class="span-11 last">
	  		<aims:column cssErrorClass="error" path="systemUser.userType">
	  		<form:label path="systemUser.userType">
	  			User Type *
	 		</form:label>
	  		<form:select path="systemUser.userType" disabled="true">
	  			<form:option value=""></form:option>
	  			<form:options items="${globalUserTypeMap}" />	
	  		</form:select>
	  		<form:errors path="systemUser.userType" cssClass="errorSimple"  />   
	  		</aims:column>
	  		<aims:column cssErrorClass="error" path="systemUser.department.departmentId">
	  		<form:label path="systemUser.department.departmentId">
	  			Company 
	 		</form:label> 
	 		<form:select id="departmentId" path="systemUser.department.departmentId" onchange="initSectionDropDown('sectionId',this.value)">
	 			<!--
	 				<form:option value="">All Department</form:option>
	 			-->
	 			<form:options items="${globalDepartment}" itemValue="departmentId" itemLabel="departmentName" />
	 		</form:select> <form:errors path="systemUser.department.departmentId" cssClass="errorSimple"  />   
	  		</aims:column>
	  		<!-- 
	  		<aims:column cssErrorClass="error" path="systemUser.section.sectionId">
	  		<form:label path="systemUser.section.sectionId">
	  			Section 
	 		</form:label>
	 		<form:select path="systemUser.section.sectionId" id="sectionId">
	 			<form:option value="">All Section</form:option>
	 		</form:select> <form:errors path="systemUser.section.sectionId" cssClass="errorSimple"  />   
	  		</aims:column>
	  		-->
	  		</div>
	  	</fieldset>
	  	<fieldset>
		<legend>Personal Info</legend>
		<div class="span-11">
		<aims:column  cssErrorClass="error" path="systemUser.personName" cssClass="clearfix">
	  		<form:label path="systemUser.personName">
	  			Person Name 
	 		</form:label>
	  		<form:input path="systemUser.personName" />
	  		<form:errors path="systemUser.personName" cssClass="errorSimple"  />
	  	</aims:column>
	  	<aims:column cssErrorClass="error" path="systemUser.nric"  cssClass="clearfix">
			<form:label path="systemUser.nric">
	  			NRIC  
	 		</form:label>
	  		<form:input path="systemUser.nric" />
	  		<form:errors path="systemUser.nric" cssClass="errorSimple"  />
		</aims:column>
	  	<aims:column cssErrorClass="error" path="systemUser.contactInfo.contactAddress" cssClass="clearfix">
	  		<form:label path="systemUser.contactInfo.contactAddress">
	  			Address 
	 		</form:label>
	  		<form:textarea path="systemUser.contactInfo.contactAddress" rows="3" cols="30" />
	  	</aims:column>
	  	<aims:column cssErrorClass="error" path="systemUser.contactInfo.contactPostalCode" cssClass="clearfix">
	  		<form:label path="systemUser.contactInfo.contactPostalCode">
	  			Postal Code 
	 		</form:label>
	  		<form:input path="systemUser.contactInfo.contactPostalCode" />
	  	</aims:column>
	  	</div>
	  	<div class="span-11">
	  	<aims:column cssErrorClass="error" path="systemUser.contactInfo.mobileNo" cssClass="clearfix">
	  		<form:label path="systemUser.contactInfo.mobileNo">
	  			Mobile No 
	 		</form:label>
	  		<form:input path="systemUser.contactInfo.mobileNo" />
	  	</aims:column>
		<aims:column cssErrorClass="error" path="systemUser.contactInfo.faxNo" cssClass="clearfix">
	  		<form:label path="systemUser.contactInfo.faxNo">
	  			Fax No 
	 		</form:label>
	  		<form:input path="systemUser.contactInfo.faxNo" />
	  	</aims:column>
	  	<aims:column cssErrorClass="error" path="systemUser.contactInfo.email" cssClass="clearfix">
	  		<form:label path="systemUser.contactInfo.email">
	  			Email 
	 		</form:label>
	  		<form:input path="systemUser.contactInfo.email" />
	  		<form:errors path="systemUser.contactInfo.email" cssClass="errorSimple"  />
	  		</aims:column>
	  		</div>
		</fieldset>

      	<div class="action" style="width:50%">
      	
	  	<c:choose>
	  		<c:when test="${systemUserForm.systemUser.lastModifiedDate==''}">
	  			<button type="submit" class="button positive">
	  			Save
	  			</button>
	  			<a href="<c:url value="/user/search" />" class="button">
	  			Back
	  			</a>
	  		</c:when>
	  		<c:when test="${systemUserForm.systemUser.lastModifiedDate!=null}">
	  				<button type="submit"  class="button positive">
	  				Update
	  				</button>
	  				<a href="javascript:window.close()" class="button">Close</a>
	  		</c:when>
	  	</c:choose>
	 </div>	
	</form:form>
	<script type="text/javascript">
		$(document).ready(function() {
			initSectionDropDown('sectionId','${systemUserForm.systemUser.department.departmentId}','${systemUserForm.systemUser.section.sectionId}');
		});
	</script>